package com.revzone.demo001.entity.OtherEntity;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

@Data
public class PageResult<T> {

    public List<T> list;
    // 分页查询所需的属性
    @ApiModelProperty("页数据条数")
    public Long pageSize = 10L;

    @ApiModelProperty("当前为第几页")
    public Long currentPage = 1L;

    @ApiModelProperty("总页数")
    private Long totalPages;

    @ApiModelProperty("总记录数")
    private Long total;


    public PageResult(IPage<T> userPage) {
        this.list = userPage.getRecords();
        this.pageSize = userPage.getSize();
        this.currentPage = userPage.getCurrent();
        this.totalPages = userPage.getPages();
        this.total = userPage.getTotal();
    }

    public PageResult(List<T> list, Long pageSize, Long currentPage, Long totalPages, Long total) {
        this.list = list;
        this.pageSize = pageSize;
        this.currentPage = currentPage;
        this.totalPages = totalPages;
        this.total = total;
    }

    public PageResult(){

    }
}
